import * as actionTypes from '../constants/store.js';

let initialState =[];

export default function store(state=initialState,action){
	switch (action.type) {
		case actionTypes.STORE_UPDATE: 
			return action.data //更新数据
		case actionTypes.STORE_ADD:
			state.unshift(action.data) //添加一项
			return state
		case actionTypes.STORE_RM:
			return state.filter((item)=>{ //过滤掉传入item
				if(item.id !==action.data.id){
					return item
				}
			})
		default:
			return state
			break;
	}
}